using HKB.Common;
using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Diagnostics;
namespace HKB.Data.Dal.H_CardTableAdapters
{
	[GeneratedCode("System.Data.Design.TypedDataSetGenerator", "2.0.0.0"), DataObject(true), HelpKeyword("vs.data.TableAdapter"), Designer("Microsoft.VSDesigner.DataSource.Design.TableAdapterDesigner, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), DesignerCategory("code"), ToolboxItem(true)]
	public class HL_CardTableAdapter : Component
	{
		private SqlDataAdapter _adapter;
		private SqlConnection _connection;
		private SqlCommand[] _commandCollection;
		private bool _clearBeforeFill;
		[System.Diagnostics.DebuggerNonUserCode]
		private SqlDataAdapter Adapter
		{
			get
			{
				if (this._adapter == null)
				{
					this.InitAdapter();
				}
				return this._adapter;
			}
		}
		[System.Diagnostics.DebuggerNonUserCode]
		internal SqlConnection Connection
		{
			get
			{
				if (this._connection == null)
				{
					this.InitConnection();
				}
				return this._connection;
			}
			set
			{
				this._connection = value;
				if (this.Adapter.InsertCommand != null)
				{
					this.Adapter.InsertCommand.Connection = value;
				}
				if (this.Adapter.DeleteCommand != null)
				{
					this.Adapter.DeleteCommand.Connection = value;
				}
				if (this.Adapter.UpdateCommand != null)
				{
					this.Adapter.UpdateCommand.Connection = value;
				}
				for (int i = 0; i < this.CommandCollection.Length; i++)
				{
					if (this.CommandCollection[i] != null)
					{
						this.CommandCollection[i].Connection = value;
					}
				}
			}
		}
		[System.Diagnostics.DebuggerNonUserCode]
		protected SqlCommand[] CommandCollection
		{
			get
			{
				if (this._commandCollection == null)
				{
					this.InitCommandCollection();
				}
				return this._commandCollection;
			}
		}
		[System.Diagnostics.DebuggerNonUserCode]
		public bool ClearBeforeFill
		{
			get
			{
				return this._clearBeforeFill;
			}
			set
			{
				this._clearBeforeFill = value;
			}
		}
		[System.Diagnostics.DebuggerNonUserCode]
		public HL_CardTableAdapter()
		{
			this.ClearBeforeFill = true;
		}
		[System.Diagnostics.DebuggerNonUserCode]
		private void InitAdapter()
		{
			this._adapter = new SqlDataAdapter();
			DataTableMapping dataTableMapping = new DataTableMapping();
			dataTableMapping.SourceTable = "Table";
			dataTableMapping.DataSetTable = "HL_Card";
			dataTableMapping.ColumnMappings.Add("CardID", "CardID");
			dataTableMapping.ColumnMappings.Add("CardType", "CardType");
			dataTableMapping.ColumnMappings.Add("CardNum", "CardNum");
			dataTableMapping.ColumnMappings.Add("CardPassword", "CardPassword");
			dataTableMapping.ColumnMappings.Add("CardMoney", "CardMoney");
			dataTableMapping.ColumnMappings.Add("CardValidNum", "CardValidNum");
			dataTableMapping.ColumnMappings.Add("CardAgentName", "CardAgentName");
			dataTableMapping.ColumnMappings.Add("CardValidUnit", "CardValidUnit");
			dataTableMapping.ColumnMappings.Add("CardEndDate", "CardEndDate");
			dataTableMapping.ColumnMappings.Add("CardState", "CardState");
			dataTableMapping.ColumnMappings.Add("CardCreateTime", "CardCreateTime");
			dataTableMapping.ColumnMappings.Add("CardUseTime", "CardUseTime");
			dataTableMapping.ColumnMappings.Add("CardSellFrom", "CardSellFrom");
			dataTableMapping.ColumnMappings.Add("CardUserName", "CardUserName");
			this._adapter.TableMappings.Add(dataTableMapping);
			this._adapter.DeleteCommand = new SqlCommand();
			this._adapter.DeleteCommand.Connection = this.Connection;
			this._adapter.DeleteCommand.CommandText = "DELETE FROM [HL_Card] WHERE (([CardID] = @Original_CardID))";
			this._adapter.DeleteCommand.CommandType = CommandType.Text;
			this._adapter.DeleteCommand.Parameters.Add(new SqlParameter("@Original_CardID", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "CardID", DataRowVersion.Original, false, null, "", "", ""));
			this._adapter.InsertCommand = new SqlCommand();
			this._adapter.InsertCommand.Connection = this.Connection;
			this._adapter.InsertCommand.CommandText = "INSERT INTO [HL_Card] ([CardType], [CardNum], [CardPassword], [CardMoney], [CardValidNum], [CardAgentName], [CardValidUnit], [CardEndDate], [CardState], [CardCreateTime], [CardUseTime], [CardSellFrom], [CardUserName]) VALUES (@CardType, @CardNum, @CardPassword, @CardMoney, @CardValidNum, @CardAgentName, @CardValidUnit, @CardEndDate, @CardState, @CardCreateTime, @CardUseTime, @CardSellFrom, @CardUserName)";
			this._adapter.InsertCommand.CommandType = CommandType.Text;
			this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CardType", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "CardType", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CardNum", SqlDbType.VarChar, 0, ParameterDirection.Input, 0, 0, "CardNum", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CardPassword", SqlDbType.VarChar, 0, ParameterDirection.Input, 0, 0, "CardPassword", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CardMoney", SqlDbType.Money, 0, ParameterDirection.Input, 0, 0, "CardMoney", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CardValidNum", SqlDbType.NVarChar, 0, ParameterDirection.Input, 0, 0, "CardValidNum", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CardAgentName", SqlDbType.VarChar, 0, ParameterDirection.Input, 0, 0, "CardAgentName", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CardValidUnit", SqlDbType.VarChar, 0, ParameterDirection.Input, 0, 0, "CardValidUnit", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CardEndDate", SqlDbType.DateTime, 0, ParameterDirection.Input, 0, 0, "CardEndDate", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CardState", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "CardState", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CardCreateTime", SqlDbType.DateTime, 0, ParameterDirection.Input, 0, 0, "CardCreateTime", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CardUseTime", SqlDbType.DateTime, 0, ParameterDirection.Input, 0, 0, "CardUseTime", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CardSellFrom", SqlDbType.VarChar, 0, ParameterDirection.Input, 0, 0, "CardSellFrom", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.InsertCommand.Parameters.Add(new SqlParameter("@CardUserName", SqlDbType.NVarChar, 0, ParameterDirection.Input, 0, 0, "CardUserName", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.UpdateCommand = new SqlCommand();
			this._adapter.UpdateCommand.Connection = this.Connection;
			this._adapter.UpdateCommand.CommandText = "UPDATE [HL_Card] SET [CardType] = @CardType, [CardNum] = @CardNum, [CardPassword] = @CardPassword, [CardMoney] = @CardMoney, [CardValidNum] = @CardValidNum, [CardAgentName] = @CardAgentName, [CardValidUnit] = @CardValidUnit, [CardEndDate] = @CardEndDate, [CardState] = @CardState, [CardCreateTime] = @CardCreateTime, [CardUseTime] = @CardUseTime, [CardSellFrom] = @CardSellFrom, [CardUserName] = @CardUserName WHERE (([CardID] = @Original_CardID))";
			this._adapter.UpdateCommand.CommandType = CommandType.Text;
			this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@CardType", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "CardType", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@CardNum", SqlDbType.VarChar, 0, ParameterDirection.Input, 0, 0, "CardNum", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@CardPassword", SqlDbType.VarChar, 0, ParameterDirection.Input, 0, 0, "CardPassword", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@CardMoney", SqlDbType.Money, 0, ParameterDirection.Input, 0, 0, "CardMoney", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@CardValidNum", SqlDbType.NVarChar, 0, ParameterDirection.Input, 0, 0, "CardValidNum", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@CardAgentName", SqlDbType.VarChar, 0, ParameterDirection.Input, 0, 0, "CardAgentName", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@CardValidUnit", SqlDbType.VarChar, 0, ParameterDirection.Input, 0, 0, "CardValidUnit", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@CardEndDate", SqlDbType.DateTime, 0, ParameterDirection.Input, 0, 0, "CardEndDate", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@CardState", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "CardState", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@CardCreateTime", SqlDbType.DateTime, 0, ParameterDirection.Input, 0, 0, "CardCreateTime", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@CardUseTime", SqlDbType.DateTime, 0, ParameterDirection.Input, 0, 0, "CardUseTime", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@CardSellFrom", SqlDbType.VarChar, 0, ParameterDirection.Input, 0, 0, "CardSellFrom", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@CardUserName", SqlDbType.NVarChar, 0, ParameterDirection.Input, 0, 0, "CardUserName", DataRowVersion.Current, false, null, "", "", ""));
			this._adapter.UpdateCommand.Parameters.Add(new SqlParameter("@Original_CardID", SqlDbType.Int, 0, ParameterDirection.Input, 0, 0, "CardID", DataRowVersion.Original, false, null, "", "", ""));
		}
		[System.Diagnostics.DebuggerNonUserCode]
		private void InitConnection()
		{
			this._connection = new SqlConnection();
			this._connection.ConnectionString = Conn.CurrenConnectionStrings;
		}
		[System.Diagnostics.DebuggerNonUserCode]
		private void InitCommandCollection()
		{
			this._commandCollection = new SqlCommand[6];
			this._commandCollection[0] = new SqlCommand();
			this._commandCollection[0].Connection = this.Connection;
			this._commandCollection[0].CommandText = "SELECT CardID, CardType, CardNum, CardPassword, CardMoney, CardValidNum, \r\n      CardAgentName, CardValidUnit, CardEndDate, CardState, CardCreateTime, \r\n      CardUseTime, CardSellFrom, CardUserName\r\nFROM HL_Card";
			this._commandCollection[0].CommandType = CommandType.Text;
			this._commandCollection[1] = new SqlCommand();
			this._commandCollection[1].Connection = this.Connection;
			this._commandCollection[1].CommandText = "DELETE FROM [HL_Card] WHERE (([CardID] = @CardID))";
			this._commandCollection[1].CommandType = CommandType.Text;
			this._commandCollection[1].Parameters.Add(new SqlParameter("@CardID", SqlDbType.Int, 4, ParameterDirection.Input, 0, 0, "CardID", DataRowVersion.Original, false, null, "", "", ""));
			this._commandCollection[2] = new SqlCommand();
			this._commandCollection[2].Connection = this.Connection;
			this._commandCollection[2].CommandText = "DeleteCards";
			this._commandCollection[2].CommandType = CommandType.StoredProcedure;
			this._commandCollection[2].Parameters.Add(new SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4, ParameterDirection.ReturnValue, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[2].Parameters.Add(new SqlParameter("@CARD_ID", SqlDbType.VarChar, 8000, ParameterDirection.Input, 0, 0, null, DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[3] = new SqlCommand();
			this._commandCollection[3].Connection = this.Connection;
			this._commandCollection[3].CommandText = "SELECT CardAgentName, CardCreateTime, CardEndDate, CardID, CardMoney, CardNum, \r\n      CardPassword, CardSellFrom, CardState, CardType, CardUseTime, CardValidNum, \r\n      CardValidUnit, CardUserName\r\nFROM HL_Card\r\nWHERE (CardID = @CardID)";
			this._commandCollection[3].CommandType = CommandType.Text;
			this._commandCollection[3].Parameters.Add(new SqlParameter("@CardID", SqlDbType.Int, 4, ParameterDirection.Input, 0, 0, "CardID", DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[4] = new SqlCommand();
			this._commandCollection[4].Connection = this.Connection;
			this._commandCollection[4].CommandText = "SELECT CardID, CardType, CardNum, CardPassword, CardMoney, CardValidNum, \r\n      CardAgentName, CardValidUnit, CardEndDate, CardState, CardCreateTime, \r\n      CardUseTime, CardSellFrom, CardUserName\r\nFROM HL_Card\r\nWHERE (CardNum = @CardNum) AND (CardPassword = @CardPassword)";
			this._commandCollection[4].CommandType = CommandType.Text;
			this._commandCollection[4].Parameters.Add(new SqlParameter("@CardNum", SqlDbType.VarChar, 50, ParameterDirection.Input, 0, 0, "CardNum", DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[4].Parameters.Add(new SqlParameter("@CardPassword", SqlDbType.VarChar, 50, ParameterDirection.Input, 0, 0, "CardPassword", DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[5] = new SqlCommand();
			this._commandCollection[5].Connection = this.Connection;
			this._commandCollection[5].CommandText = "pr_GetCardbyStatus";
			this._commandCollection[5].CommandType = CommandType.StoredProcedure;
			this._commandCollection[5].Parameters.Add(new SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4, ParameterDirection.ReturnValue, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""));
			this._commandCollection[5].Parameters.Add(new SqlParameter("@StrSQL", SqlDbType.VarChar, 1000, ParameterDirection.Input, 0, 0, null, DataRowVersion.Current, false, null, "", "", ""));
		}
		[DataObjectMethod(DataObjectMethodType.Select, true), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual H_Card.HL_CardDataTable GetCards()
		{
			this.Adapter.SelectCommand = this.CommandCollection[0];
			H_Card.HL_CardDataTable hL_CardDataTable = new H_Card.HL_CardDataTable();
			this.Adapter.Fill(hL_CardDataTable);
			return hL_CardDataTable;
		}
		[DataObjectMethod(DataObjectMethodType.Select, false), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual H_Card.HL_CardDataTable GetCardByCardID(int CardID)
		{
			this.Adapter.SelectCommand = this.CommandCollection[3];
			this.Adapter.SelectCommand.Parameters[0].Value = CardID;
			H_Card.HL_CardDataTable hL_CardDataTable = new H_Card.HL_CardDataTable();
			this.Adapter.Fill(hL_CardDataTable);
			return hL_CardDataTable;
		}
		[DataObjectMethod(DataObjectMethodType.Select, false), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual H_Card.HL_CardDataTable GetCardByCardNumCardPass(string CardNum, string CardPassword)
		{
			this.Adapter.SelectCommand = this.CommandCollection[4];
			if (CardNum == null)
			{
				this.Adapter.SelectCommand.Parameters[0].Value = System.DBNull.Value;
			}
			else
			{
				this.Adapter.SelectCommand.Parameters[0].Value = CardNum;
			}
			if (CardPassword == null)
			{
				this.Adapter.SelectCommand.Parameters[1].Value = System.DBNull.Value;
			}
			else
			{
				this.Adapter.SelectCommand.Parameters[1].Value = CardPassword;
			}
			H_Card.HL_CardDataTable hL_CardDataTable = new H_Card.HL_CardDataTable();
			this.Adapter.Fill(hL_CardDataTable);
			return hL_CardDataTable;
		}
		[DataObjectMethod(DataObjectMethodType.Select, false), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual H_Card.HL_CardDataTable GetCardByStatus(string StrSQL)
		{
			this.Adapter.SelectCommand = this.CommandCollection[5];
			if (StrSQL == null)
			{
				this.Adapter.SelectCommand.Parameters[1].Value = System.DBNull.Value;
			}
			else
			{
				this.Adapter.SelectCommand.Parameters[1].Value = StrSQL;
			}
			H_Card.HL_CardDataTable hL_CardDataTable = new H_Card.HL_CardDataTable();
			this.Adapter.Fill(hL_CardDataTable);
			return hL_CardDataTable;
		}
		[HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int Update(H_Card.HL_CardDataTable dataTable)
		{
			return this.Adapter.Update(dataTable);
		}
		[HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int Update(H_Card dataSet)
		{
			return this.Adapter.Update(dataSet, "HL_Card");
		}
		[HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int Update(DataRow dataRow)
		{
			return this.Adapter.Update(new DataRow[]
			{
				dataRow
			});
		}
		[HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int Update(DataRow[] dataRows)
		{
			return this.Adapter.Update(dataRows);
		}
		[DataObjectMethod(DataObjectMethodType.Delete, false), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int DeleteCard(int CardID)
		{
			SqlCommand sqlCommand = this.CommandCollection[1];
			sqlCommand.Parameters[0].Value = CardID;
			ConnectionState state = sqlCommand.Connection.State;
			if ((sqlCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
			{
				sqlCommand.Connection.Open();
			}
			int result;
			try
			{
				result = sqlCommand.ExecuteNonQuery();
			}
			finally
			{
				if (state == ConnectionState.Closed)
				{
					sqlCommand.Connection.Close();
				}
			}
			return result;
		}
		[DataObjectMethod(DataObjectMethodType.Delete, false), HelpKeyword("vs.data.TableAdapter"), System.Diagnostics.DebuggerNonUserCode]
		public virtual int DeleteCards(string CARD_ID)
		{
			SqlCommand sqlCommand = this.CommandCollection[2];
			if (CARD_ID == null)
			{
				sqlCommand.Parameters[1].Value = System.DBNull.Value;
			}
			else
			{
				sqlCommand.Parameters[1].Value = CARD_ID;
			}
			ConnectionState state = sqlCommand.Connection.State;
			if ((sqlCommand.Connection.State & ConnectionState.Open) != ConnectionState.Open)
			{
				sqlCommand.Connection.Open();
			}
			int result;
			try
			{
				result = sqlCommand.ExecuteNonQuery();
			}
			finally
			{
				if (state == ConnectionState.Closed)
				{
					sqlCommand.Connection.Close();
				}
			}
			return result;
		}
	}
}
